/*
 *
 * Copyright (C) 2019 Zealcomm Inc. (https://www.zealcomm.com)
 *
 */
#ifndef IRTC_BASE_OBJC_IRTCLOCALCAMERASTREAM_H_
#define IRTC_BASE_OBJC_IRTCLOCALCAMERASTREAM_H_

#import <IRTC/IRTCAudioFileStateProtocol.h>
#import <IRTC/IRTCFrameGeneratorProtocol.h>
#import <IRTC/IRTCLocalStream.h>
#import <IRTC/IRTCMacros.h>
#import <IRTC/IRTCMediaFormat.h>

NS_ASSUME_NONNULL_BEGIN
@class IRTCStreamConstraints;
/// This class represent a local stream.<br>这个类代表了一条本地媒体流。
IRTC_OBJC_EXPORT
@interface IRTCLocalCameraStream : IRTCLocalStream
/**
  Create an IRTCLocalStream from mic and camera with given
  constraints.<br>根据指定配置参数从麦克风和摄像头创建一条IRTCLocalStream。
  @param constraints Constraints for creating the stream. The stream will not be
  impacted if changing constraints after it is
  created.<br>创建媒体流的配置参数。如果在创建完媒体流后改变这个参数，媒体流不会变。
  @return On success, an IRTCLocalStream object. If nil, the outError parameter
  contains an NSError instance describing the
  problem.<br>如果成功，返回一个IRTCLocalStream对象。如果返回nil(空)，outError会包含问题所在的NSError的实例。
*/
- (instancetype)initWithConstratins:(IRTCStreamConstraints*)constraints
                              error:(NSError**)outError;

/**
  Create an IRTCLocalStream from audio frame generator (or mic) and camera with
  given
  constraints.<br>根据指定配置参数从音频帧生成器(或者麦克风)和摄像头创建一条IRTCLocalStream。
  @param constraints Constraints for creating the stream. The stream will not be
  impacted if changing constraints after it is
  created.<br>创建媒体流的配置参数。如果在创建完媒体流后改变这个参数，媒体流不会变。
  @param audioFrameGenerator An implementation which feeds audio frames to SDK.
  If |enabled| is NO, generator will be ignored. It cannot be nil if customized
  audio input is enabled. If generator is nil, customized audio input will be
  disabled.<br>一个将音频帧输入到SDK的音频帧生成器实现。如果|enabled|是NO，帧生成器会被忽略。
  如果启用了自定义音频输入，这个值不能是nil(空)。如果帧生成器是nil(空)，自定义音频输入将不被启用。
  @return On success, an IRTCLocalStream object. If nil, the outError parameter
  contains an NSError instance describing the
  problem.<br>如果成功，返回一个IRTCLocalStream对象。如果返回nil(空)，outError会包含问题所在的NSError的实例。
*/
- (instancetype)initWithConstratins:(IRTCStreamConstraints*)constraints
                              error:(NSError**)outError
                audioFrameGenerator:
                    (nullable id<RTCAudioFrameGeneratorProtocol>)
                        audioFrameGenerator;

/**
  Create an IRTCLocalStream from audio file and camera with given
  constraints.<br>根据指定配置参数从音频文件和摄像头创建一条IRTCLocalStream。
  @param constraints Constraints for creating the stream. The stream will not be
  impacted if changing constraints after it is
  created.<br>创建媒体流的配置参数。如果在创建完媒体流后改变这个参数，媒体流不会变。
  @param audioFilePath An implementation which feeds audio file to
  SDK.<br>将一个音频文件送入SDK的具体实现。
  @param audioFileType Audio file type.<br>音频文件类型。
  @param audioFileStateDelegate Audio file state call
  back.<br>音频文件状态回调。
  @param audioFileIsLoop Set whether in a loop.<br>设置是否循环。
  @return On success, an IRTCLocalStream object. If nil, the outError parameter
  contains an NSError instance describing the
  problem.<br>如果成功，返回一个IRTCLocalStream对象。如果返回nil(空)，outError会包含问题所在的NSError的实例。
*/
- (instancetype)
    initWithConstratinsAudioFileInfo:(IRTCStreamConstraints*)constraints
                       audioFilePath:(NSString*)filePath
              audioFileStateDelegate:(nullable id<IRTCAudioFileStateProtocol>)
                                         audioFileStateDelegate
                     audioFileIsLoop:(BOOL)isLoop
                               error:(NSError**)outError;

/**
  Create an IRTCLocalStream from audio file and camera with given
  constraints.<br>根据指定配置参数从音频文件和摄像头创建一条IRTCLocalStream。
  @param constraints Constraints for creating the stream. The stream will not be
  impacted if changing constraints after it is
  created.<br>创建媒体流的配置参数。如果在创建完媒体流后改变这个参数，媒体流不会变。
  @param pcmFilePath An implementation which feeds pcm file to
  SDK.<br>将一个PCM文件送入SDK的具体实现。
  @param pcmChannelNumber Audio file channel number.<br>声道数量。
  @param pcmSampleRate Audio file sample rate.<br>音频采样率。
  @param pcmFileStateDelegate Audio file state call back.<br>音频文件状态回调。
  @param pcmFileIsLoop Set whether in a loop.<br>设置是否循环。
  @return On success, an IRTCLocalStream object. If nil, the outError parameter
  contains an NSError instance describing the
  problem.<br>如果成功，返回一个IRTCLocalStream对象。如果返回nil(空)，outError会包含问题所在的NSError的实例。
*/
- (instancetype)
    initWithConstratinsPcmFileInfo:(IRTCStreamConstraints*)constraints
                       pcmFilePath:(NSString*)filePath
                  pcmChannelNumber:(NSUInteger)channelNumber
                     pcmSampleRate:(NSUInteger)sampleRate
              pcmFileStateDelegate:
                  (nullable id<IRTCAudioFileStateProtocol>)pcmFileStateDelegate
                     pcmFileIsLoop:(BOOL)isLoop
                             error:(NSError**)outError;

/**
  @brief Switch the camera.<br>切换摄像头。
 */
- (void)switchCameraOnSuccess:(nullable void (^)())onSuccess
                    onFailure:(nullable void (^)(NSError*))onFailure;

/**
  @brief Stop the stream.<br>将媒体流的第一条视频轨绑定到视频渲染器上。
 */
- (void)stop;

/**
  Start to read audio file for publishing and
  playing.<br>开始读取音频文件来发布和播放。
*/
- (BOOL)startAudioFile;

/**
Stop to read audio file.<br>停止读取音频文件。
*/
- (BOOL)stopAudioFile;

@end
NS_ASSUME_NONNULL_END
#endif  // IRTC_BASE_OBJC_IRTCLOCALCAMERASTREAM_H_